*------------------------------------------------------------------------------
* Dollars, Desks, and Development: The Impact of Local Sales Tax Revenue Redistribution on Recipient Programs in North Carolina

* Authors: Alex Combs and Whitney Afonso

* Runs final models, generating results from (Eqs. 2-5)
*------------------------------------------------------------------------------

use analysis_data, clear

*------------------------------------------------------------------------------
* Continuous treatment; revenue outcomes
* Each did_multiplegt_dyn command saves results for making event study plots
*------------------------------------------------------------------------------

* LST per capita
did_multiplegt_dyn log_r_pc_rev_394042 cty_number year r_pc_ART44524, /// 
 controls(log_pop log_r_pc_rev_control_lst) effects(3) placebo(3) /// 
 drop_if_d_miss_before_first_switch save_results(cte_lstrev)
 
xtreg log_r_pc_rev_394042 c.r_pc_ART44524#i.post log_r_pc_rev_control_lst /// 
 log_pop i.year if dcdh_sample==1, fe robust
 
* Property tax revenue
did_multiplegt_dyn log_r_pc_rev_prop_tax cty_number year r_pc_ART44524, ///
 controls(log_pop log_r_pc_rev_control_prop) effects(3) placebo(3) /// 
 drop_if_d_miss_before_first_switch save_results(cte_proprev)
 
xtreg log_r_pc_rev_prop_tax c.r_pc_ART44524#i.post /// 
 log_r_pc_rev_control_prop log_pop i.year if dcdh_sample==1, fe robust

* Property Tax Rate
did_multiplegt_dyn taxrate cty_number year r_pc_ART44524, ///
 controls(log_pop log_r_pc_rev_control_prop) effects(3) placebo(3) /// 
 drop_if_d_miss_before_first_switch /// 
 save_results(cte_proptaxrate)

xtreg taxrate c.r_pc_ART44524#i.post log_r_pc_rev_control_prop /// 
 log_pop i.year if dcdh_sample==1, fe robust
 
* Non-property other revenue
did_multiplegt_dyn log_r_pc_rev_less_lstprop cty_number year r_pc_ART44524, ///
 controls(log_pop log_r_pc_rev_control_onoprop) effects(3) placebo(3) ///
 drop_if_d_miss_before_first_switch /// 
 save_results(cte_nonproprev)

xtreg log_r_pc_rev_less_lstprop c.r_pc_ART44524#i.post /// 
 log_r_pc_rev_control_onoprop log_pop i.year if dcdh_sample==1, fe robust
 
*------------------------------------------------------------------------------
* Continuous treatment; expenditure outcomes
* Each did_multiplegt_dyn command saves results for making event study plots
*------------------------------------------------------------------------------

* Earmarked expenditures
did_multiplegt_dyn log_r_pc_exp_earmark cty_number year r_pc_ART44524, ///
 controls(log_r_pc_all_oth_rev log_pop expobj_school_allother) effects(3) placebo(3) /// 
 drop_if_d_miss_before_first_switch /// 
 save_results(cte_earmarks)

xtreg log_r_pc_exp_earmark c.r_pc_ART44524#i.post log_r_pc_all_oth_rev /// 
 log_pop i.year if dcdh_sample==1, fe robust
 
* Non-earmarked
did_multiplegt_dyn log_r_pc_exp_nonearmark cty_number year r_pc_ART44524, ///
 controls(log_r_pc_all_oth_rev log_pop) effects(3) placebo(3) /// 
 drop_if_d_miss_before_first_switch /// 
 save_results(cte_nonearmark)

xtreg log_r_pc_exp_nonearmark c.r_pc_ART44524#i.post log_r_pc_all_oth_rev /// 
 log_pop i.year if dcdh_sample==1, fe robust

* K-12 expenditures
did_multiplegt_dyn log_r_pc_k12opcap cty_number year r_pc_ART44524, ///
 controls(log_r_pc_all_oth_rev log_pop expobj_school_allother) effects(3) /// 
 placebo(3) drop_if_d_miss_before_first_switch /// 
 save_results(cte_k12opcap)

xtreg log_r_pc_k12opcap c.r_pc_ART44524#i.post log_r_pc_all_oth_rev /// 
 log_pop expobj_school_allother i.year, fe robust

* Community college
did_multiplegt_dyn log_r_pc_exp_commcoll cty_number year r_pc_ART44524, ///
 controls(log_r_pc_all_oth_rev log_pop) effects(3) placebo(3) /// 
 drop_if_d_miss_before_first_switch /// 
 save_results(cte_commcoll)

xtreg log_r_pc_exp_commcoll c.r_pc_ART44524#i.post log_r_pc_all_oth_rev /// 
 log_pop i.year if dcdh_sample==1, fe robust

* Econ development
did_multiplegt_dyn log_r_pc_exp_econdev cty_number year r_pc_ART44524, ///
 controls(log_r_pc_all_oth_rev log_pop) effects(3) placebo(3) /// 
 drop_if_d_miss_before_first_switch save_results(cte_econdev)

xtreg log_r_pc_exp_econdev c.r_pc_ART44524#i.post log_r_pc_all_oth_rev /// 
 log_pop i.year if dcdh_sample==1, fe robust 

* K-12 operating
did_multiplegt_dyn log_r_pc_k12op cty_number year r_pc_ART44524, ///
 controls(log_r_pc_all_oth_rev log_pop expobj_school_allother) effects(3) /// 
 placebo(3) save_results(cte_k12op)
 
xtreg log_r_pc_k12op c.r_pc_ART44524#i.post log_r_pc_all_oth_rev log_pop /// 
 expobj_school_allother i.year if dcdh_sample==1, fe robust

* K-12 capital
did_multiplegt_dyn log_r_pc_k12cap cty_number year r_pc_ART44524, ///
 controls(log_r_pc_all_oth_rev log_pop expobj_school_allother) effects(3) /// 
 placebo(3) save_results(cte_k12cap)

xtreg log_r_pc_k12cap c.r_pc_ART44524#i.post log_r_pc_all_oth_rev /// 
 log_pop expobj_school_allother i.year if dcdh_sample==1, fe robust 
 
*------------------------------------------------------------------------------
* Net revenue group analysis
*------------------------------------------------------------------------------
 
xtreg r_pc_ART44524 ib2016.year##i.treat_group log_pop if dcdh_sample==1, /// 
 fe robust

xtreg log_r_pc_rev_394042 ib2016.year##i.treat_group log_pop /// 
 log_r_pc_rev_control_lst if dcdh_sample==1, fe robust

xtreg log_r_pc_rev_less_lstprop ib2016.year##i.treat_group log_pop /// 
 log_r_pc_rev_control_onoprop if dcdh_sample==1, fe robust

xtreg log_r_pc_rev_prop_tax ib2016.year##i.treat_group log_pop /// 
 log_r_pc_rev_control_prop if dcdh_sample==1, fe robust

xtreg taxrate ib2016.year##i.treat_group log_pop /// 
 log_r_pc_rev_control_prop if dcdh_sample==1, fe robust

xtreg log_r_pc_exp_earmark ib2016.year##i.treat_group log_pop /// 
 log_r_pc_all_oth_rev if dcdh_sample==1, fe robust

xtreg log_r_pc_exp_nonearmark ib2016.year##i.treat_group log_pop /// 
 log_r_pc_all_oth_rev if dcdh_sample==1, fe robust

xtreg log_r_pc_k12opcap ib2016.year##i.treat_group log_pop /// 
 log_r_pc_all_oth_rev expobj_school_allother if dcdh_sample==1, fe robust

xtreg log_r_pc_exp_commcoll ib2016.year##i.treat_group log_pop /// 
 log_r_pc_all_oth_rev if dcdh_sample==1, fe robust

xtreg log_r_pc_exp_econdev ib2016.year##i.treat_group log_pop /// 
 log_r_pc_all_oth_rev if dcdh_sample==1, fe robust
 
*------------------------------------------------------------------------------
* Robustness check: Exclusion of net loss receivers
*------------------------------------------------------------------------------
* LST per capita
did_multiplegt_dyn log_r_pc_rev_394042 cty_number year r_pc_ART44524 if nlr==0, /// 
 controls(log_pop log_r_pc_rev_control_lst) effects(3) placebo(3) /// 
 drop_if_d_miss_before_first_switch graph_off
 
* Property tax revenue
did_multiplegt_dyn log_r_pc_rev_prop_tax cty_number year r_pc_ART44524 if nlr==0, ///
 controls(log_pop log_r_pc_rev_control_prop) effects(3) placebo(3) /// 
 drop_if_d_miss_before_first_switch graph_off

* Property Tax Rate
did_multiplegt_dyn taxrate cty_number year r_pc_ART44524 if nlr==0, ///
 controls(log_pop log_r_pc_rev_control_prop) effects(3) placebo(3) /// 
 drop_if_d_miss_before_first_switch graph_off
 
* Non-property other revenue
did_multiplegt_dyn log_r_pc_rev_less_lstprop cty_number year r_pc_ART44524 if nlr==0, ///
 controls(log_pop log_r_pc_rev_control_onoprop) effects(3) placebo(3) ///
 drop_if_d_miss_before_first_switch graph_off

* Earmarked expenditures
did_multiplegt_dyn log_r_pc_exp_earmark cty_number year r_pc_ART44524 if nlr==0, ///
 controls(log_r_pc_all_oth_rev log_pop) effects(3) placebo(3) /// 
 drop_if_d_miss_before_first_switch graph_off
 
* Non-earmarked
did_multiplegt_dyn log_r_pc_exp_nonearmark cty_number year r_pc_ART44524 if nlr==0, ///
 controls(log_r_pc_all_oth_rev log_pop) effects(3) placebo(3) /// 
 drop_if_d_miss_before_first_switch graph_off

* K-12 expenditures
did_multiplegt_dyn log_r_pc_k12opcap cty_number year r_pc_ART44524 if nlr==0, ///
 controls(log_r_pc_all_oth_rev log_pop expobj_school_allother) effects(3) /// 
 placebo(3) drop_if_d_miss_before_first_switch graph_off

* Community college
did_multiplegt_dyn log_r_pc_exp_commcoll cty_number year r_pc_ART44524 if nlr==0, ///
 controls(log_r_pc_all_oth_rev log_pop) effects(3) placebo(3) /// 
 drop_if_d_miss_before_first_switch graph_off

* Econ development
did_multiplegt_dyn log_r_pc_exp_econdev cty_number year r_pc_ART44524 if nlr==0, ///
 controls(log_r_pc_all_oth_rev log_pop) effects(3) placebo(3) /// 
 drop_if_d_miss_before_first_switch graph_off

* K-12 operating
did_multiplegt_dyn log_r_pc_k12op cty_number year r_pc_ART44524 if nlr==0, ///
 controls(log_r_pc_all_oth_rev log_pop expobj_school_allother) effects(3) /// 
 placebo(3) drop_if_d_miss_before_first_switch graph_off

* K-12 capital
did_multiplegt_dyn log_r_pc_k12cap cty_number year r_pc_ART44524 if nlr==0, ///
 controls(log_r_pc_all_oth_rev log_pop expobj_school_allother) effects(3) /// 
 placebo(3) drop_if_d_miss_before_first_switch graph_off

*------------------------------------------------------------------------------
* Robustness check: Balance test
*------------------------------------------------------------------------------

local balancetest pct_male pct_hispanic pct_white pct_black pct_orace /// 
 pct_pov medinc pop
foreach var of local balancetest {
	diff `var', p(post) t(receive_treat) cl(cty_fips)
}

*------------------------------------------------------------------------------
* Robustness check: Inclusion of median income as a control
*------------------------------------------------------------------------------
 
* LST per capita
did_multiplegt_dyn log_r_pc_rev_394042 cty_number year r_pc_ART44524, /// 
 controls(log_pop log_r_pc_rev_control_lst medinc) effects(3) placebo(3) /// 
 drop_if_d_miss_before_first_switch graph_off
 
* Property tax revenue
did_multiplegt_dyn log_r_pc_rev_prop_tax cty_number year r_pc_ART44524, ///
 controls(log_pop log_r_pc_rev_control_prop medinc) effects(3) placebo(3) /// 
 drop_if_d_miss_before_first_switch graph_off

* Property Tax Rate
did_multiplegt_dyn taxrate cty_number year r_pc_ART44524, ///
 controls(log_pop log_r_pc_rev_control_prop medinc) effects(3) placebo(3) /// 
 drop_if_d_miss_before_first_switch graph_off
 
* Non-property other revenue
did_multiplegt_dyn log_r_pc_rev_less_lstprop cty_number year r_pc_ART44524, ///
 controls(log_pop log_r_pc_rev_control_onoprop medinc) effects(3) placebo(3) ///
 drop_if_d_miss_before_first_switch graph_off

* Earmarked expenditures
did_multiplegt_dyn log_r_pc_exp_earmark cty_number year r_pc_ART44524, ///
 controls(log_r_pc_all_oth_rev log_pop medinc) effects(3) placebo(3) /// 
 drop_if_d_miss_before_first_switch graph_off
 
* Non-earmarked
did_multiplegt_dyn log_r_pc_exp_nonearmark cty_number year r_pc_ART44524, ///
 controls(log_r_pc_all_oth_rev log_pop medinc) effects(3) placebo(3) /// 
 drop_if_d_miss_before_first_switch graph_off

* K-12 expenditures
did_multiplegt_dyn log_r_pc_k12opcap cty_number year r_pc_ART44524, ///
 controls(log_r_pc_all_oth_rev log_pop expobj_school_allother medinc) effects(3) /// 
 placebo(3) drop_if_d_miss_before_first_switch graph_off

* Community college
did_multiplegt_dyn log_r_pc_exp_commcoll cty_number year r_pc_ART44524, ///
 controls(log_r_pc_all_oth_rev log_pop medinc) effects(3) placebo(3) /// 
 drop_if_d_miss_before_first_switch graph_off

* Econ development
did_multiplegt_dyn log_r_pc_exp_econdev cty_number year r_pc_ART44524, ///
 controls(log_r_pc_all_oth_rev log_pop medinc) effects(3) placebo(3) /// 
 drop_if_d_miss_before_first_switch graph_off

* K-12 operating
did_multiplegt_dyn log_r_pc_k12op cty_number year r_pc_ART44524, ///
 controls(log_r_pc_all_oth_rev log_pop expobj_school_allother medinc) effects(3) /// 
 placebo(3) drop_if_d_miss_before_first_switch graph_off

* K-12 capital
did_multiplegt_dyn log_r_pc_k12cap cty_number year r_pc_ART44524, ///
 controls(log_r_pc_all_oth_rev log_pop expobj_school_allother medinc) effects(3) /// 
 placebo(3) drop_if_d_miss_before_first_switch graph_off

*------------------------------------------------------------------------------
* Robustness check: Placebo test for K12 operating
*------------------------------------------------------------------------------
 
gen red_rev_tminus1 = r_pc_ART44524

sort cty_number year 

replace red_rev_tminus1 = F1.red_rev_tminus1

bysort cty_number: ipolate red_rev_tminus1 year, epolate gen(irev)

replace red_rev_tminus1 = irev if red_rev_tminus1==.

did_multiplegt_dyn log_r_pc_k12op cty_number year red_rev_tminus1, ///
 controls(log_r_pc_all_oth_rev log_pop expobj_school_allother) effects(4) /// 
 placebo(2)

* Two years back from actual treatment

gen red_rev_tminus2 = r_pc_ART44524

replace red_rev_tminus2 = F2.red_rev_tminus2

bysort cty_number: ipolate red_rev_tminus2 year, epolate gen(irev2)

replace red_rev_tminus2 = irev if red_rev_tminus2==.

did_multiplegt_dyn log_r_pc_k12op cty_number year red_rev_tminus2, ///
 controls(log_r_pc_all_oth_rev log_pop expobj_school_allother) effects(5) /// 
 placebo(1)
 
 
 
 